#ifndef _BUFFER_DEC
#define _BUFFER_DEC

#include <string>
#include <iostream>

namespace mylib {
	class Buffer {
	public:
		Buffer(std::istream &in);	
		~Buffer() { if( buf ) {delete [] buf; buf=0;} }
	
		class Out_of_mem {};
		class Invalid_input {};
		class Overflow {};

		bool get(char &c);
		bool eof() { return end; }			// the end?
		size_t ret(size_t n=1);		// go back
		int tellg();				// get current position
		Buffer &seekg(int pos);				// seek get position
		size_t maxret();					// return maximum return number 
	private:
		Buffer(const Buffer &buf) {}
		Buffer &operator=(const Buffer &buf) {}
	private:
		std::istream *in_file;				// 0 label read  from input stream
		char *buf;
		int next_pos;
		bool pass_half;					// to label whether pass half of this vector
		bool end;
	};
}
#endif
